package com.xiaotu.server.service;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.xiaotu.common.model.TVRecordModel;


@Service
public class SupplementService extends BaseService{

	public void saveTvRecord(TVRecordModel record){
		this.save("insert_tv_record", record);
	}
	
	public void saveTvRecordDay(Map record){
		this.save("insert_tv_record_day", record);
	}
	
	/**
	 * 获取前一天日播放量
	 * @param record
	 * @return
	 */
	public List<Map> getYeaterdayTvRecord(TVRecordModel record){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Calendar c =Calendar.getInstance();
		c.add(Calendar.DATE, -1);
		Map<String,String> params = new HashMap<String,String>();
		params.put("tvid", record.getTvId());
		params.put("resourceSiteId", record.getResourceSiteId());
		params.put("tvName", record.getTvName());
		params.put("yesterday",sdf.format(c.getTime()));
		return this.getList("selectTvRecordDay", params);
	}
	
	@Override
	protected String getKey() {
		
		return "TVRecordMapper";
	}

}
